package com.crane.oss.sports;

import com.crane.common.framework.http.apache.HttpClientUtils;
import com.crane.common.framework.http.apache.HttpResult;
import com.crane.oss.xunfei.req.*;
import com.crane.oss.xunfei.resp.*;
import com.fasterxml.jackson.core.type.TypeReference;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class XunFeiClassCourseAnalysisApiService extends XunFeiApiService {



    /**
     * 查询课堂月份数据情况
     */
    public ApiListResponse<ClassCourseAnalysisIndexResp> getAnalysisClassCourseIndex(QueryClassAnalysisIndexReq request, String sid, String did, String uid){
        Map<String, String> params = getStringStringMap(request, sid, did, uid);
        HttpResult httpResult= HttpClientUtils.get(xunFeiAppConfig.getUrl()+"/analysis/class/index/course",params);
        if(httpResult.isSuccess()){
            ApiListResponse<ClassCourseAnalysisIndexResp> response=httpResult.getDataObjectByJson(new TypeReference<ApiListResponse<ClassCourseAnalysisIndexResp>>(){});
            return response;
        }
        return ApiListResponse.buildFailure();
    }


    /**
     * 查询课堂月份数据详细概况
     */
    public ApiSingleResponse<ClassCourseIdAnalysisResp> getAnalysisClassCourseId(QueryAnalysisClassCourseIdReq request, String sid, String did, String uid){
        Map<String, String> params = getStringStringMap(request, sid, did, uid);
        HttpResult httpResult= HttpClientUtils.get(xunFeiAppConfig.getUrl()+"/analysis/class/course/content/"+request.getCourseId(),params);
        if(httpResult.isSuccess()){
            ApiSingleResponse<ClassCourseIdAnalysisResp> response=httpResult.getDataObjectByJson(new TypeReference<ApiSingleResponse<ClassCourseIdAnalysisResp>>(){});
            return response;
        }
        return ApiSingleResponse.buildFailure();
    }

    /**
     * 查询课堂id数据详细情况
     */
    public ApiSingleResponse<ClassCourseIdIndexAnalysisResp> getAnalysisClassCourseIndex(QueryAnalysisClassCourseIdReq request, String sid, String did, String uid){
        Map<String, String> params = getStringStringMap(request, sid, did, uid);
        HttpResult httpResult= HttpClientUtils.get(xunFeiAppConfig.getUrl()+"/analysis/class/course/content/index/"+request.getCourseId(),params);
        if(httpResult.isSuccess()){
            ApiSingleResponse<ClassCourseIdIndexAnalysisResp> response=httpResult.getDataObjectByJson(new TypeReference<ApiSingleResponse<ClassCourseIdIndexAnalysisResp>>(){});
            return response;
        }
        return ApiSingleResponse.buildFailure();
    }


    /**
     * 课堂记录指数标准达标学生
     */
    public ApiSingleResponse<ClassCourseAnalysisContentQuotaResp> getAnalysisClassCourseContentQuota(QueryAnalysisClassCourseIdReq request, String sid, String did, String uid){
        Map<String, String> params = getStringStringMap(request, sid, did, uid);
        HttpResult httpResult= HttpClientUtils.get(xunFeiAppConfig.getUrl()+"/analysis/class/course/content/quota/count/"+request.getCourseId(),params);
        if(httpResult.isSuccess()){
            ApiSingleResponse<ClassCourseAnalysisContentQuotaResp> response=httpResult.getDataObjectByJson(new TypeReference<ApiSingleResponse<ClassCourseAnalysisContentQuotaResp>>(){});
            return response;
        }
        return ApiSingleResponse.buildFailure();
    }


    /**
     * 课堂记录指数标准未达标学生详情
     *
     */
    public ApiListResponse<ClassCourseStudentQuotaResp> getAnalysisClassCourseContentQuotaStudent(QueryAnalysisClassCourseIdReq request, String sid, String did, String uid){
        Map<String, String> params = getStringStringMap(request, sid, did, uid);
        HttpResult httpResult= HttpClientUtils.get(xunFeiAppConfig.getUrl()+"/analysis/class/course/content/quota/student/"+request.getCourseId(),params);
        if(httpResult.isSuccess()){
            ApiListResponse<ClassCourseStudentQuotaResp> response=httpResult.getDataObjectByJson(new TypeReference<ApiListResponse<ClassCourseStudentQuotaResp>>(){});
            return response;
        }
        return ApiListResponse.buildFailure();
    }

    /**
     * 课堂记录学生列表
     */
    public ApiListResponse<ClassCourseAnalysisStudentListResp> getAnalysisClassCourseStudentList(QueryAnalysisClassCourseStudentListReq request, String sid, String did, String uid){
        Map<String, String> params = getStringStringMap(request, sid, did, uid);
        String url=xunFeiAppConfig.getUrl()+"/analysis/class/course/students/"+request.getCourseId();
        HttpResult httpResult= HttpClientUtils.get(url,params);
        if(httpResult.isSuccess()){
            ApiListResponse<ClassCourseAnalysisStudentListResp> response=httpResult.getDataObjectByJson(new TypeReference<ApiListResponse<ClassCourseAnalysisStudentListResp>>(){});
            return response;
        }
        return ApiListResponse.buildFailure();
    }


    /**
     * 课堂记录学生详情
     */
    public ApiSingleResponse<ClassCourseAnalysisStudentInfoResp> getAnalysisClassCourseStudentInfo(QueryAnalysisClassCourseStudentReq request, String sid, String did, String uid){
        Map<String, String> params = getStringStringMap(request, sid, did, uid);
        HttpResult httpResult= HttpClientUtils.get(xunFeiAppConfig.getUrl()+"/analysis/class/course/student/"+request.getCourseId()+ "/"+request.getStudentId(),params);
        if(httpResult.isSuccess()){
            ApiSingleResponse<ClassCourseAnalysisStudentInfoResp> response=httpResult.getDataObjectByJson(new TypeReference<ApiSingleResponse<ClassCourseAnalysisStudentInfoResp>>(){});
            return response;
        }
        return ApiSingleResponse.buildFailure();
    }

    /**
     * 课堂记录数据分析
     */
    public ApiListResponse<ClassCourseAnalysisDataResp> getAnalysisClassCourseData(QueryAnalysisClassCourseDataReq request, String sid, String did, String uid){
        Map<String, String> params = getStringStringMap(request, sid, did, uid);
        HttpResult httpResult= HttpClientUtils.get(xunFeiAppConfig.getUrl()+"/analysis/class/course/data",params);
        if(httpResult.isSuccess()){
            ApiListResponse<ClassCourseAnalysisDataResp> response=httpResult.getDataObjectByJson(new TypeReference<ApiListResponse<ClassCourseAnalysisDataResp>>(){});
            return response;
        }
        return ApiListResponse.buildFailure();
    }

    /**
     * 课堂记录学期班级统计数据
     */
    public ApiSingleResponse<ClassCourseAnalysisCycleResp> getAnalysisClassCourseStatistic(QueryAnalysisCycleClassCourseReq request, String sid, String did, String uid){
        Map<String, String> params = getStringStringMap(request, sid, did, uid);
        HttpResult httpResult= HttpClientUtils.get(xunFeiAppConfig.getUrl()+"/analysis/class/term/class/statistic/"+request.getCycleId()+"/"+request.getClassId(),params);
        if(httpResult.isSuccess()){
            ApiSingleResponse<ClassCourseAnalysisCycleResp> response=httpResult.getDataObjectByJson(new TypeReference<ApiSingleResponse<ClassCourseAnalysisCycleResp>>(){});
            return response;
        }
        return ApiSingleResponse.buildFailure();
    }


    /**
     * 课堂记录学期班级学生列表
     */
    public ApiListResponse<ClassCourseAnalysisStudentStatisticListResp> getAnalysisClassCourseStudentStatistic(QueryAnalysisCycleClassCourseStudentReq request, String sid, String did, String uid){
        Map<String, String> params = getStringStringMap(request, sid, did, uid);
        HttpResult httpResult= HttpClientUtils.get(xunFeiAppConfig.getUrl()+"/analysis/class/term/students/statistic/"+request.getCycleId()+"/"+request.getClassId(),params);
        if(httpResult.isSuccess()){
            ApiListResponse<ClassCourseAnalysisStudentStatisticListResp> response=httpResult.getDataObjectByJson(new TypeReference<ApiListResponse<ClassCourseAnalysisStudentStatisticListResp>>(){});
            return response;
        }
        return ApiListResponse.buildFailure();
    }


    /**
     * 课堂记录学期班级学生列表
     */
    public ApiSingleResponse<ClassCourseCycleAnalysisStudentInfoResp> getAnalysisCycleStudentInfo(QueryAnalysisCycleStudentReq request, String sid, String did, String uid){
        Map<String, String> params = getStringStringMap(request, sid, did, uid);
        HttpResult httpResult= HttpClientUtils.get(xunFeiAppConfig.getUrl()+"/analysis/class/term/student/statistic/"+request.getCycleId()+"/"+request.getStudentId(),params);
        if(httpResult.isSuccess()){
            ApiSingleResponse<ClassCourseCycleAnalysisStudentInfoResp> response=httpResult.getDataObjectByJson(new TypeReference<ApiSingleResponse<ClassCourseCycleAnalysisStudentInfoResp>>(){});
            return response;
        }
        return ApiSingleResponse.buildFailure();
    }

    public ApiListResponse<ClassCourseAnalysisStandardResp> getAnalysisCourseStandard(QueryAnalysisClassCourseStandardReq request, String sid, String did, String uid){
        Map<String, String> params = getStringStringMap(request, sid, did, uid);
        HttpResult httpResult= HttpClientUtils.get(xunFeiAppConfig.getUrl()+"/analysis/class/course/content/standard",params);
        if(httpResult.isSuccess()){
            ApiListResponse<ClassCourseAnalysisStandardResp> response=httpResult.getDataObjectByJson(new TypeReference<ApiListResponse<ClassCourseAnalysisStandardResp>>(){});
            return response;
        }
        return ApiListResponse.buildFailure();
    }



    public static void main(String[] args) {
        XunFeiClassCourseAnalysisApiService xunFeiApiService=new XunFeiClassCourseAnalysisApiService();
//        QueryClassAnalysisIndexReq queryClassAnalysisIndexReq =new QueryClassAnalysisIndexReq();
//        queryClassAnalysisIndexReq.setCampusId("1");
//        queryClassAnalysisIndexReq.setClassIds("1,2,3,4,5,6,7,8,9,10,11,12,13,14");
//        queryClassAnalysisIndexReq.setMonth("2022年04月");
//        System.out.println(xunFeiApiService.getAnalysisClassCourseIndex(queryClassAnalysisIndexReq,"87", null,"3"));


        QueryAnalysisClassCourseStudentListReq queryAnalysisCycleClassCourseReq=new QueryAnalysisClassCourseStudentListReq();
        queryAnalysisCycleClassCourseReq.setCourseId("e63d4d9ddc1345e190a181476766f977");
        queryAnalysisCycleClassCourseReq.setGender("1");
        queryAnalysisCycleClassCourseReq.setPage(1);
        queryAnalysisCycleClassCourseReq.setLimit(10);
        System.out.println(xunFeiApiService.getAnalysisClassCourseStudentList(queryAnalysisCycleClassCourseReq,"87", null,"3"));

//        QueryAnalysisCycleClassCourseStudentReq req =new QueryAnalysisCycleClassCourseStudentReq();
//        req.setCycleId("1");
//        req.setClassId("2");
//        req.setPage(1);
//        req.setLimit(2);
//        System.out.println(xunFeiApiService.getAnalysisClassCourseStudentStatistic(req,"87", null,"3"));


//        QueryAnalysisCycleStudentReq req =new QueryAnalysisCycleStudentReq();
//        req.setCycleId("1");
//        req.setStudentId("11");
//        System.out.println(xunFeiApiService.getAnalysisCycleStudentInfo(req,"87", null,"3"));
//                System.out.println(xunFeiApiService.getAnalysisClassCourseStudentInfo(req,"87", null,"3"));

//        QueryAnalysisClassCourseDataReq queryAnalysisClassCourseDataReq=new QueryAnalysisClassCourseDataReq();
//        queryAnalysisClassCourseDataReq.setClassIds("1");
//        queryAnalysisClassCourseDataReq.setLimit("5");
//        System.out.println(xunFeiApiService.getAnalysisClassCourseData(queryAnalysisClassCourseDataReq,"87", null,"3"));

//        QueryAnalysisClassCourseStandardReq req =new QueryAnalysisClassCourseStandardReq();
//        req.setClassId("2");
//        req.setClassType(0);
//        System.out.println(xunFeiApiService.getAnalysisCourseStandard(req,"87", null,"3"));

//
    }

}

